package com.renbang.utils.messgedigest;

import static org.junit.Assert.*;  

import java.math.BigInteger;

import org.junit.Test;  

/** 
 *  
 * @author 梁栋 
 * @version 1.0 
 * @since 1.0 
 */  
public class PBECoderTest {  

    @Test  
    public void test() throws Exception {  
        String inputStr = "123";  
        System.err.println("原文: " + inputStr);  
        byte[] input = inputStr.getBytes();  

        String pwd = "efg";  
        System.err.println("密码: " + pwd);  

        byte[] salt = PBECoder.initSalt();
        String code = Coder.encryptBASE64(salt);
        System.out.println("盐base64码"+code);
        byte[] data = PBECoder.encrypt(input, pwd, salt);  

        System.err.println("加密后: " + PBECoder.encryptBASE64(data));  

        byte[] output = PBECoder.decrypt(data, pwd, salt);  
        String outputStr = new String(output);  

        System.err.println("解密后: " + outputStr);  
        assertEquals(inputStr, outputStr);  
    }  

}  